const { DataTypes, Sequelize } = require("sequelize");
const sequelize = require("./sequelizeBaseConfig.js");

const Page = sequelize.define(
  "Page",
  {
    id: {
      type: DataTypes.BIGINT,
      comment: "ID",
      autoIncrement: true, //自增
      primaryKey: true, //主键
    },
    created_at: {
      type: DataTypes.DATE,
      comment: "创建时间",
      defaultValue: Sequelize.literal("CURRENT_TIMESTAMP"), //如果没有设置该字段的值则使用默认
    },
    updated_at: {
      type: DataTypes.DATE,
      comment: "更新时间",
      defaultValue: Sequelize.literal(
        "CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP"
      ),
    },
    name: {
      type: DataTypes.STRING,
      comment: "首页",
      allowNull: true,
    },
    label: {
      type: DataTypes.STRING,
      comment: "页面标签",
      allowNull: true,
    },
    cover: {
      type: DataTypes.STRING,
      comment: "封面",
      allowNull: true,
    },
  },
  { tableName: "page", timestamps: false }
);

module.exports = {
  Page,
};
